package org.ponly.uno4j;

import org.ponly.uno4j.core.impl.EmbeddedUnoClientImpl;
import org.ponly.uno4j.support.D2sService;
import org.ponly.uno4j.support.D2sTask;
import org.ponly.uno4j.support.SimpleD2sServiceImpl;
import org.ponly.uno4j.support.TaskListener;

/**
 */
public class Demo2 {
    public static void main(String[] args) {
        String unoUrl = "uno:socket,host=localhost,port=8888;";
        EmbeddedUnoClientImpl unoServer = new EmbeddedUnoClientImpl(unoUrl, 8888, 1);
        unoServer.start();
        D2sService s = new SimpleD2sServiceImpl(unoServer, 1);
        s.setTaskListener(new TaskListener() {
            @Override
            public void taskToBeExecuted(D2sTask task) {
                System.out.println("开始执行任务:" + task.getTaskKey());
            }

            @Override
            public void taskWasExecuted(D2sTask task, Exception executionException) {
                System.out.println("任务执行完毕:" + task.getTaskKey() + ", 异常:" + executionException);
                if (null != executionException) {
                    executionException.printStackTrace();
                }
            }
        });
        D2sTask task = D2sTask.create("1", "D:/艾漫电商系统数据库设计说明书.rtf", "D:/a.pdf.swf");
        s.submit(task);
        s.shutdown();
    }
}
